package com.yitiao.data_algorithms.leetcode.editor.cn;

import com.yitiao.data_algorithms.leetcode.editor.cn.base.ListNode;
import com.yitiao.data_algorithms.leetcode.editor.cn.base.TreeNode;

class OptimalDivision {
    // 2022-08-29 11:08:55
    public static void main(String[] args) {
        Solution solution = new OptimalDivision().new Solution();
    }

    //leetcode submit region begin(Prohibit modification and deletion)
    class Solution {
        public String optimalDivision(int[] nums) {
            int n = nums.length;
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < n; i++) {
                sb.append(nums[i]);
                if (i + 1 < n) sb.append("/");
            }
            if (n > 2) {
                sb.insert(sb.indexOf("/") + 1, "(");
                sb.append(")");
            }
            return sb.toString();
        }
    }
//leetcode submit region end(Prohibit modification and deletion)

}